home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 26
/
Cream of the Crop 26.iso
/
program
/
qlib205.zip
/
QLIB.ZIP
/
TXT
/
PACK.TXT
< prev
next >
Wrap
Text File
|
1997-02-10
|
4KB
|
77 lines
packed file IO
--------------
Pack file IO is a set of functions that allow you to copy all files
for a project into one file. This means all the grafix and sound files (or
whatever) can be kept in one file and then accessed normally thru the
standard IO functions (ie: open,close,read,etc.)
This massive packed files are created using a utility called PACKIT.
To make a packed file just use PACKIT within a directory of files to pack.
Give it a parameter of a file to output to.
EG: packit ..\data.000
Then use the following functions to load in data.000 and the files within.
PACKIT.C is included if you need the source.
pack_init,nooffiles:word,packs:word
- initalizes the system (alloc's ram and enabling sub-system)
- nooffiles specifies how many files can be loaded within all
the packed files which will be opened
- packs specifies how many packed files may be opened with the pack_open()
and pack_open_hdr() functions
pack_uninit
- frees buffers and disables the whole sub-system
- all files are closed!
- it is not necessary to call this during program exit
pack_open,filename:dword
- loads a packed file so that the files within can be opened
- returns a handle(word) that can be used with pack_close()
pack_open_hdr,filename:dword,hdr:dword
- loads a packed file so that the files within can be opened
- hdr must point to the header of the pack file which must already be
loaded into memory
- returns a handle(word) that can be used with pack_close()
pack_close,hand:dword
- closes a packed file making all files with the pack file no longer
accessable and frees the DOS file handle used with the pack file.
Packit also has a new option that will output the header to a different
file which you can incorperate into your EXE file to protect the files
within the pack file if you wish. These new PACK files must be opened with
pack_open_hdr() and you must have the header already in memory.
Each pack file opened is kept open for the entire duration of the program
so that means each pack file will need a file handle (so don't open too
many file handles). Most system have about 40 handles so opening more
than 30 pack files would be too many.
Once you've inited and opened data files just simply use open() to open the
files within. What happens is that if open() cannot find the file in any
packed file it then allows DOS to attempt to open the file as usually.
If it does find it in a packed file , it returns the already open handle and lseeks the file to
the begining of that file within the pack file. If an attempt is made to close
the file it is just ignored and returned successful. This is very useful
because you can use other routines such as 'g_loadfnt' with a file within
a packed file and it will use it just like any other file. One last note,
the packed files are opened in read only mode with Pack_open.
Pack_init() lets you set the limit of how many files within the pack files
can be loaded and how many packed files can be opened when you call. This can
only be called once!
NOTE: Pack.asm keeps internal vars set to the current file opened and therefore
only one file can be opened at a time from with in the packed files. The
actual handles for each packed file are kept open. When anything tries
to open one of them pack.asm just returns the handle and lseeks the pack file
to the proper position. Plus any lseek done on the file is handled properly.
If a file is contained in two or more packed files the most recently opened
pack file will be used instead. This is good for adding patches to games
and other stuff. (like how DOOM adds wads which simply overides files)
If a file exists within a packed file and this file also exists in the
current directory then you will only be able to load the one in the
packed file, unless you have not called pack_init() and pack_open() yet.
Cool eh...?